package clientCommunicationHandler;

import java.util.Vector;

public class BackStack {
	private Vector<String> lastCommand ;
	public BackStack(){
		this.lastCommand = new Vector<String>();
	}
	
	public void addNewCommand(String newCommand){
		if(!(this.lastCommand.contains(newCommand))){
			this.lastCommand.add(newCommand);
			System.out.println("adding " + newCommand);
		}
		
	}
	public String getLastCommand(){
		String temp = "";
		if(this.lastCommand.size()>1){
			temp = this.lastCommand.elementAt(this.lastCommand.size()-2);
			this.lastCommand.remove(this.lastCommand.size()-1);
			
		}
		return temp;
	}
	public String viewLastCommand(){
		String temp = "";
		if(this.lastCommand.size() > 0){
			temp = this.lastCommand.elementAt(this.lastCommand.size()-1);
		}
		return temp;
	}
	
	public void restartBack(){
		this.lastCommand.removeAllElements();
	}

}
